import { REGEX_PASSWORD_CCOMPLEX, REGEX_CHINESE } from '@/utils/validate'
const rules = {
  avatar: [{ required: true, message: '请上传管理员头像' }],
  userName: [
    {
      required: true,
      message: '请输入登录账号，字母或数字（6-20位以内）',
      trigger: 'blur'
    },
    {
      pattern: /^[A-Za-z0-9]+$/,
      message: '请输入字母或数字（6-20位以内）'
    },
    {
      min: 6,
      max: 20,
      message: '请输入字母或数字（6-20位以内）'
    }
  ],
  password: [
    {
      required: true,
      message: '请输入登录密码',
      trigger: 'blur'
    },
    {
      pattern: REGEX_PASSWORD_CCOMPLEX,
      message: '6-16个位，可输入英文、数字，特殊符号；字母、数字和特殊符号至少包含两种',
      trigger: 'blur'
    }
  ],
  roleId: [
    {
      required: true,
      message: '请选择所属角色',
      trigger: 'change'
    }
  ],
  realName: [
    {
      required: true,
      message: '请输入管理员真实姓名',
      trigger: 'blur'
    },
    {
      min: 1,
      max: 5,
      message: '限制1-5个字符'
    },
    {
      pattern: REGEX_CHINESE,
      message: '只能输入中文'
    }
  ],
  telephone: [
    {
      required: true,
      message: '请输入员工联系电话',
      trigger: 'blur'
    },
    {
      pattern: /^((13[0-9])|(14[0-9])|(15[0-3,5-9])|(17[0-9])|(18[0-9])|16[0-9]|(19[0-9]))\d{8}$/,
      message: '请输入正确格式的联系电话'
    }
  ],
  email: [
    {
      required: true,
      message: '请输入邮箱号',
      trigger: 'blur'
    },
    {
      pattern:
        /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,
      message: '请输入正确格式的邮箱'
    }
  ],
  status: [
    {
      required: true,
      message: '是否启用不能为空',
      trigger: 'change'
    }
  ]
}

export default rules
